
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    <title>注册</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link rel="shortcut icon" type="image/x-icon" href="https://wwl.ycws.cc/image/backgroundimage/e.ico">
	<!-- css样式 -->
	<style type="text/css">
		#preview2{width:355px;height:190px;border:1px solid #000;overflow:hidden; text-align:center;}
		/* #imghead {filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=image);} */
	</style>
	<!-- jquery代码 -->
	<script src="js/jquery-1.11.3.min.js"></script>
	<!-- 图片预览 -->
	<script type="text/javascript">
       	//图片上传预览    IE是用了滤镜。
       function previewImage2(file){
            var cutout=document.getElementById('filepath2').value;	//获取文件路径
        	var newCutout=cutout.substring(cutout.indexOf('.'));	//判断后缀名是否为图片
        	debugger;
        	var jpg='.jpg',png='.png',jpeg='.jpeg',gif='.gif';
        	if(jpg == newCutout || png == newCutout || jpeg == newCutout || gif == newCutout){
        		var MAXWIDTH  = 332; 
          		var MAXHEIGHT = 187;
          		var div = document.getElementById('preview2');
          	if (file.files && file.files[0]){
              	div.innerHTML ='<img id=imghead2>';
              	var img = document.getElementById('imghead2');
              	img.onload = function(){
                var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
                img.width  =  rect.width;
                img.height =  rect.height;
                img.style.marginTop = 2+'px';  
                /* var file=document.getElementById('filepath2').value;
                var params= {filepath:file};
                $.ajax({
    				url:"${path}/weixinbassm/user/UserInformationFist",
    				data:params,
    				type:"post",
    				async:false,
    				success:function(date){
    					debugger;
    					if(date==1){ 
    						alert("图片检测成功")			
						}else{
							alert("图片检测失败重新选择图片")
							window.location.href = "${path}/weixinbassm/add.jsp";
						}
    				},
    				error:function(){
    					alert("数据加载失败");
    				}
    			}); */
              }
	            var reader = new FileReader();
	            reader.onload = function(evt){img.src = evt.target.result;}
	            reader.readAsDataURL(file.files[0]);
          	}else{//兼容IE
	            var sFilter='filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="';
	            file.select();
	            var src = document.selection.createRange().text;
	            div.innerHTML = '<img id=imghead>';
	            var img = document.getElementById('imghead');
	            img.filters.item('DXImageTransform.Microsoft.AlphaImageLoader').src = src;
	            var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
	            status =('rect:'+rect.top+','+rect.left+','+rect.width+','+rect.height);
	            div.innerHTML = "<div id=divhead style='width:"+rect.width+"px;height:"+rect.height+"px;margin-top:"+rect.top+"px;"+sFilter+src+"\"'></div>";
	       	}
	      	}else{
        		alert('上传的不是图片,请重新上传');
        	}
        }     
        function clacImgZoomParam( maxWidth, maxHeight, width, height ){
            var param = {top:0, left:0, width:width, height:height};
            if( width>maxWidth || height>maxHeight ){
                rateWidth = width / maxWidth;
                rateHeight = height / maxHeight;
                if( rateWidth > rateHeight ){
                    param.width =  maxWidth;
                    param.height = Math.round(height / rateWidth);
                }else{
                    param.width = Math.round(width / rateHeight);
                    param.height = maxHeight;
                }
            }
            param.left = Math.round((maxWidth - param.width) / 2);
            param.top = Math.round((maxHeight - param.height) / 2);
            return param;
        }
</script> 
	<script type="text/javascript">	
		$(document).ready(function(){
			$("#add").click(function(){	
				var files = $('#filepath2').prop('files');
				var file=document.getElementById('filepath2').value;
				var name=$("#yname").val();
				var sex=$("#ysex").val();
				var phone=$("#yphone").val();
				var detailed=$("#ydetailed").val();
				var sfzid=$("#ysfzid").val();
				var params= {filepath:file,name:$("#yname").val(),phone:$("#yphone").val(),detailed:$("#ydetailed").val(),sex:$("#ysex").val()};
				var formData = new FormData();
				debugger;
				formData.append('file',files[0]);
				formData.append('name',name);
				formData.append('sex',sex);
				formData.append('phone',phone);
				formData.append('sfzid',sfzid);
				formData.append('detailed',detailed);
				//判断上传要求
				if(name == ""){
					alert("请输入姓名");
				}else if(detailed == ""){
					alert("请输入单元楼");
				}else if(sfzid == ""){
					alert("请输入身份证");
				}else if(phone == ""){
					alert("请输入电话号码");
				}else{
					$.ajax({
	    				url:"${path}/weixinbassm/user/UserInformation",
	    				fileElementId:"filepath2",
	    				data:formData,
	    				type:"post",
	    				async:false,
	    				processData: false,
	    				contentType: false,
	    				success:function(date){
	    					debugger;
	    					if(date==1){ 
	    						window.location.href = "${path}/weixinbassm/user/showMyProduct";
							}else{
								alert("资料有误重新输入")
							}
	    				},
	    				error:function(){
	    					alert("数据加载失败");
	    				}
	    			});
				}
			});
		});
	</script>
	<script type="text/javascript">
	$(function(){
    		$("#rootun").click(function(e){
    			window.location.href = "${path}/weixinbassm/user/showMyProduct";
    		});
	});
	
    </script>
	</head>
	<body style="margin:0px" >
	<div align="center" >
	<div style="padding-right: 400px;"><img src="img/6.png">
	<span style="font-size:21; border-bottom-color: #4F4F2F;"></span>
	&nbsp;
	<span style="width: 60px; height: 30px; color: white;font-size: 14;color:#4F4F2F;">注册用户</span>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	<a href="${path}/weixinbassm/user/showMyProduct" rootun" style="width: 60px; height: 40px; color: white; font-size: 20;color:#4F4F2F;">返回列表······</a>
	</div>
	<div >
  		<div style="padding-top:6px; background-color: #f0f0f0">
    	<form id="addform" method="post" enctype="multipart/form-data" style="padding-right: 32%;" >
    		<table border="0"  cellpadding="0" cellspacing="0" >
       		<tr>
				<td colspan="3">
					<div id="preview2"><img id="imghead2" ></div>
				</td>
			</tr>
			<tr>
	
				<td colspan="3">
					<input type="file" name="filepath" id="filepath2" value="" onchange="previewImage2(this)" style="width: 180px;" multiple/>
				</td>
				
			</tr>
    		<tr>
	    		<td height="85" align="right">姓名 :</td>
	    		<td colspan="2" align="left">
	    			<input type="text" name="yname" id="yname" value="" style="width: 270px; height: 40px;"/>
	    		</td>
	    		
    		</tr>
    		<tr>
	    		<td height="85" align="right">性别 :</td>
	    		<td colspan="2" align="left">
	    			<select name="ysex"  id ="ysex" style="width: 270px; height: 40px;">
	    				<option>男</option>
	    				<option>女</option>
	    			</select>
	    		</td>
    		</tr> 
    		<tr>
    		<td height="85" align="right">手机号码:</td>
	    		<td  colspan="2" align="left">
	    			<input type="text" name="yphone" id="yphone"   style="width:270px; height:40px;" />
	    		</td>
    		</tr>
    		<tr>
    		<td height="85" align="left">身份证号码:</td>
	    		<td  colspan="2" align="left">
	    			<input type="text" name="ysfzid" id="ysfzid"   style="width:270px; height:40px;" />
	    		</td>
    		</tr> 			
    		<tr>
	    		<td height="85" align="left">单元/楼/室:</td>
	    		<td  colspan="2" align="left">
	    			<input type="text" name="ydetailed" id="ydetailed" value="" style="width:270px; height:40px;"/>
	    		</td>
    		</tr>
    		<tr align="right" >
    			<td colspan="3" height="75px;">
    				<input type="button" id="add" value="提交" style="width: 160px; height: 40px; background-color: #FF0000; color: white; font-size: 20px;"/>
    			</td>
    		</tr>
    		</table>
    	</form>
  </div>
  </div>
  <p style="font-size: 15">咨询电话：0755-86133729　　公司地址：广东省深圳市龙华新区留仙大道24号彩悦大厦10楼</p>
  <p style="font-size: 15">&copy;   2013-2015深圳市万物联有限公司版权所有　丨　粤ICP备13071979号-2</p>
  </div>	
  </body>
</html>
